package chai.ningning.files;

import java.io.File;
import java.io.IOException;

public class FileTest3 {

    public static void main(String[] args) throws IOException {

       File fod = new File("D:/");

       if ( fod.exists() ){
           if( fod.isDirectory() ){
               System.out.println( fod + "是个目录");
               File[] fods = fod.listFiles();
               for (int i = 0; i < fods.length; i++) {
                   File fd = fods[i];
                   System.out.print("\t");
                   System.out.print(fd.isDirectory() ? "目录" : " 文件");
                   System.out.print( fd );
                   System.out.println( fd.isFile() ? ( fd.length() +"bytes." ) : "");
               }
           }else {
               System.out.println( fod + "是个文件");
               System.out.println("\t");
               System.out.println( fod +" " + fod.length() + "bytes." );
           }
       }else {
           System.out.println(fod + " null ");
       }
    }
}
